package com.jel.WiKikonwledge.Controller;

import com.alibaba.fastjson.JSONArray;
import com.jel.WiKikonwledge.Dao.GetSon;
import com.jel.WiKikonwledge.Dao.GetSonlmpl;
import com.jel.WiKikonwledge.Service.GetAll;
import com.jel.WiKikonwledge.Service.GetAlllmpl;
import com.jel.WiKikonwledge.bean.cont;
import com.jel.WiKikonwledge.bean.graph;
import com.jel.WiKikonwledge.bean.user;
import com.jel.WiKikonwledge.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * @author curbert:jiangenlai
 * @description
 * @date 2022-05-24 19:46:57
 * @PACKAGE_NAME:com.jel.WiKikonwledge.Controller
 */

@RestController
@RequestMapping("/control")
@CrossOrigin(origins="*")
@Slf4j
public class contController {
    @GetMapping("/getQuery")
    public Object getQuery(@RequestParam("id") int id, @RequestParam("name") String name){
        ArrayList<cont> values;
        GetSon fs =  new GetSonlmpl();
        System.out.println(name);
        values = fs.gObjects(name);
        return values;
    }
    @GetMapping("/getTree")
    public Object getTree(@RequestParam("id") String id, @RequestParam("name") String name){
        graph values;
        GetAll fs =  new GetAlllmpl();
        GetSon fd = new GetSonlmpl();
        List<Object> arr = fd.tree(id,"P279");
        values = fs.graph(arr);
        return values;
    }
    @GetMapping("/getName")
    public Object getName(@RequestParam("name") String name){
        GetSon fs = new GetSonlmpl();
//        System.out.println(name);
        user answer = fs.data(name);
        System.out.println(answer);
        return answer;
    }
}
